package com.example.studykt.util;


import android.content.Context;

import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;


public class RefreshUtils {

    public static void initList(Context context, RecyclerView recyclerView, int type) {
        LinearLayoutManager ms= new LinearLayoutManager(context);
        ms.setOrientation(type);// 设置 recyclerview 布局方式为
        recyclerView.setLayoutManager(ms);

    }
    //GridView
    public static void initGrid(RecyclerView recyclerView, int Number) {
        StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(Number, StaggeredGridLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(staggeredGridLayoutManager);

    }
    /**
     * 设置listView区分线
     *
     * @param context
     * @param recyclerView
     * @param height       高
     * @param color        颜色
     */
    public static void initList(Context context, RecyclerView recyclerView, int type, int height, int color) {
        recyclerView.addItemDecoration(new DividerItemDecoration(context, type, MyUtils.dip2px(context, height), ContextCompat.getColor(context, color)));
        LinearLayoutManager layoutManager = new LinearLayoutManager(context);
        layoutManager.setOrientation(type);
        recyclerView.setLayoutManager(layoutManager);

    }
}
